package com.onlyphoto.onlymall.mvp.presenter

import android.content.Context
import com.onlyphoto.onlymall.base.BaseNetworkResponse
import com.onlyphoto.onlymall.base.BaseObserver

import com.onlyphoto.onlymall.mvp.contract.COrders
import com.onlyphoto.onlymall.mvp.model.MOrdersImpl
import com.onlyphoto.onlymall.base.BasePresenter
import com.onlyphoto.onlymall.bean.response.OrderBean


class POrdersImpl(mContext: Context, mView: COrders.IVOrders) : BasePresenter<COrders.IVOrders, MOrdersImpl>(mContext, mView, MOrdersImpl()), COrders.IPOrders {
    override fun getOrders(status: Int, pageNum: Int) {
        mModel.requestOrders(status, pageNum, object : BaseObserver<ArrayList<OrderBean>>(mContext.get()){
            override fun onSuccess(data: ArrayList<OrderBean>?, msg: String?) {
                if (data == null) {
                    if (pageNum == 1) {
                        mView.showEmpty()
                    } else {
                        mView.showNoMore()
                    }
                }
                mView.getOrdersSuccess(data!!)
            }

            override fun onCodeError(t: BaseNetworkResponse<ArrayList<OrderBean>>?) {
            }

            override fun onFailure(e: Throwable?) {
            }

            override fun onRequestStart() {
            }

            override fun onFinally() {
            }
        })
    }
}
